from tortoise import Tortoise


async def run():
    await Tortoise.init(
        {
            # 这里面指定两个不同的数据库，虽然它填写的都是一样的
            "connections": {
                "first": {
                    "engine": "tortoise.backends.sqlite",
                    "credentials": {"file_path": "example.sqlite3"},
                },
                "second": {
                    "engine": "tortoise.backends.sqlite",
                    "credentials": {"file_path": "example1.sqlite3"},
                },
            },
            # 可以指定多个不同的models, 嗯，它指定的也是一样的
            "apps": {
                "tournaments": {"models": ["__main__"], "default_connection": "first"},
                "events": {"models": ["__main__"], "default_connection": "second"},
            },
        }
    )
    # await Tortoise.generate_schemas()
    # 选取数据库
    client = Tortoise.get_connection("first")
    # 选取 models
    second_client = Tortoise.get_connection("second")
    # 然后这下面就可以进行orm操作了
